package cn.pw.test.com.news.adapter;

import android.view.View;
import android.widget.ImageView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import cn.pw.test.com.news.R;
import cn.pw.test.com.news.bean.VideoBean;
import tech.com.commoncore.manager.GlideManager;

import static cn.pw.test.com.news.manager.NewsPathManger.NEWS_VIDEO_DETAIL;

public class VideoAdapter extends BaseQuickAdapter<VideoBean, BaseViewHolder> {

    public VideoAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, final VideoBean item) {
        ImageView videoImg = helper.itemView.findViewById(R.id.video_item_image);

        helper.setText(R.id.video_item_title, item.getTitle());

        GlideManager.loadImg(item.getUrl(), videoImg, R.drawable.news_icon_default_start_img);

        helper.itemView.findViewById(R.id.video_item_play).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ARouter.getInstance()
                        .build(NEWS_VIDEO_DETAIL)
                        .withSerializable("videoNews", item)
                        .greenChannel().navigation();
            }
        });
    }
}
